/*
 * Copyright @ 苏州瑞云信息技术有限公司 All rights reserved.
 */
package work.lock.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Sakura Shen
 * @description
 * @date 2021/10/18
 */
public class ReentrantLockTest2 {

    ReentrantLock lock = new ReentrantLock();

    void m1() throws InterruptedException {
//        lock.lock();
        for(int i=0;i<10;i++) {
            Thread.sleep(Long.parseLong("1000"));
            System.out.println(i);
        }
//        lock.unlock();
    }


    public static void main(String[] args) {

        ReentrantLockTest2 reentrantLock1 = new ReentrantLockTest2();
        ReentrantLockTest2 reentrantLock2 = new ReentrantLockTest2();
        new Thread(()-> {
            try {
                reentrantLock1.m1();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(()-> {
            try {
                reentrantLock2.m1();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}

